package com.itheima.controller;

import com.itheima.pojo.Student;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("student")
public class SwaggerController implements SwaggerIntetface {
    //测试无参接口
    @Override
    @GetMapping("hello")
    public String hello(){
        return "hello";
    }
    //测试 queryString(问号传参) 风格的参入参数
    @Override
    @GetMapping
    public Student modifyStudentNum(@RequestParam("num") String num){

        return new Student(num, "xiaozhi", 18, "parts");
    }
    //测试Restful风格的参入参数(path)
    @Override
    @GetMapping("{name}")
    public Student modifyStudentName(@PathVariable("name") String name){
        return new Student("007", name, 18, "parts");
    }

    //请求体传参(json格式的数据
    @Override
    @PostMapping
    public Student modifyStudent(@RequestBody Student student){
        student.setName("modifyName");
        return student;
    }
    //综合测试
    @Override
    @PutMapping("{id}")
    public Student mofidyStudentBynNum(@PathVariable("id") String id,
                                       @RequestParam("name") String name,
                                       @RequestBody Student student) {
        student.setName(name);
        student.setStuNo(id);
        return student;
    }
}
